<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="{{url('admin/catalog')}}" method="get">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="hidden" name="page" value="{{$catalogs->currentPage()}}">
        <input type="hidden" name="orderField" value="{{$request->input('orderField', 'id')}}">
        <input type="hidden" name="orderDirection" value="{{$request->input('orderDirection', 'asc')}}">

        <div class="bjui-searchBar">
            <label>名称：</label><input name="name" size="10" value="{{$request->input('name')}}">
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            &nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);"
               data-icon="undo">清空查询</a>
            <div class="pull-right">
                <a class="btn btn-default" data-icon="plus" href="{{url('admin/catalog/add')}}" data-toggle="dialog" data-id="catalog_add"
                   data-title="添加分类" data-width="900" data-height="600" data-mask="true">增加</a>
            </div>
        </div>
    </form>
</div>
<div class="bjui-pageContent">
    <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
        <thead>
        <tr>
            <th width="40">id</th>
            <th>名称</th>
            <th>级别</th>
            <th>上级分类id</th>
            <th>上级分类名称</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($catalogs as $catalog)
            <tr data-id="{{$catalog->id}}">
                <td>{{$catalog->id}}</td>
                <td>{{$catalog->name}}</td>
                <td>{{$catalog->level}}级</td>
                <td>@if($catalog->p_catalog){{$catalog->p_id}}@endif</td>
                <td>@if($catalog->p_catalog){{$catalog->p_catalog->name}}@endif</td>
                <td>
                    <a href="{{url('/admin/catalog/edit/' . $catalog->id)}}" class="btn btn-green" data-toggle="dialog" data-id="catalog_edit"
                       data-title="编辑-{{$catalog->name}}" data-width="900" data-height="600" data-mask="true">编辑</a>
                    <a href="{{url('/admin/catalog/delete/' . $catalog->id)}}" class="btn btn-red" data-toggle="doajax" data-type="get"
                       data-confirm-msg="确定要删除该行信息吗？">删除</a>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
    <div class="pages">
        <span>每页{{config('view')['numPerPage']}}条，共 {{$catalogs->total()}} 条</span>
    </div>
    <div class="pagination-box" data-toggle="pagination" data-total="{{$catalogs->total()}}" data-page-size="{{config('view')['numPerPage']}}"
         data-page-current="{{$catalogs->currentPage()}}"></div>
</div>